package hflyeer.gitee.com.controller;

import hflyeer.gitee.com.entity.Log;
import hflyeer.gitee.com.service.LogService;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller("logController")
public class LogController {

    @Resource(name = "logService")
    private LogService logService;

    /**
     * /log/system.do
     * 系统日志
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void system(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Log> sysLog = logService.getSysLog();
        request.setAttribute("LIST",sysLog);
        request.setAttribute("TYPE","系统");
        request.getRequestDispatcher("../log_list.jsp").forward(request,response);
    }

    /**
     * /log/login.do
     * 登录日志
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Log> sysLog = logService.getLoginLog();
        request.setAttribute("LIST",sysLog);
        request.setAttribute("TYPE","登入");
        request.getRequestDispatcher("../log_list.jsp").forward(request,response);
    }

    /**
     * /log/operation.do
     * 操作日志
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void operation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Log> sysLog = logService.getOpeLog();
        request.setAttribute("LIST",sysLog);
        request.setAttribute("TYPE","操作");
        request.getRequestDispatcher("../log_list.jsp").forward(request,response);
    }

}
